/*
 * Copyright © 2024-2025 Wenze Wei
 *
 * This file is part of StadionOS.
 *
 * This Source Code Form is subject to the terms of the GNU General Public License, v. 2.0.
 * You can obtain a copy of the GPL at
 * https://www.gnu.org/licenses/old-licenses/gpl-2.0.html.
 *
 * Software distributed under the License is distributed on an "AS IS" basis,
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
 * the specific language governing rights and limitations under the License.
 */

#ifndef STADIONOS_ANIMATION_H
#define STADIONOS_ANIMATION_H

#include <stdint.h>
#include <math.h>
#include <time.h>

typedef enum {
    EASE_LINEAR,
    EASE_OUT_QUAD,
    EASE_IN_OUT_CUBIC,
    EASE_IN_OUT_QUAD
} EaseType;

typedef struct {
    int32_t start_time;
    float duration;
    EaseType ease_type;
    
    float start_x, start_y, target_x, target_y;
    float start_width, start_height, target_width, target_height;
    
    struct {
        float m[4][4];
    } transform_matrix;
    struct {
        float m[4][4];
    } target_transform;
    void (*update_callback)(void *user_data, float x, float y, float width, float height, void *matrix);
    void *user_data;
} WindowAnimation;

uint32_t animation_get_time();
void     animation_init(WindowAnimation* anim, float duration_ms, EaseType ease_type);
int      animation_update(WindowAnimation* anim);
float    animation_calculate_ease(EaseType type, float progress);
#endif // STADIONOS_ANIMATION_H